package com.sc.VenusQueryBeta.presenter.hotel.tabs;

import com.hengjun.kingstar.sdk.utils.LogUtils;
import com.sc.VenusQueryBeta.contract.hotel.tabs.OverSeaContract;
import com.sc.VenusQueryBeta.model.bean.home.OverSeasBean;
import com.sc.VenusQueryBeta.model.hotel.tabs.OverSeaModel;

import io.reactivex.functions.Consumer;

/**
 * Created by Administrator on 2018/11/9.
 */

public class OverSeaPresenter extends OverSeaContract.OverSeaPresenter {
    @Override
    protected OverSeaContract.IOverSeaModel getModel() {
        return OverSeaModel.newInstance();
    }

    @Override
    public void onStart() {

    }

    @Override
    public void getOversea(int vipClubId) {
        mRxManager.register(mIModel.getoversea(vipClubId).subscribe(new Consumer<OverSeasBean>() {

            @Override
            public void accept(OverSeasBean overSeasBean) throws Exception {
                if (mIView != null)
                    mIView.showOverseaDataSuccess(overSeasBean);
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                LogUtils.e("error=" + throwable.getLocalizedMessage());
                if (mIView != null) {
//                    if (mIView.isVisiable())
//                        mIView.showToast("Network error.");
                    mIView.showNetworkError();
                }
            }
        }));
    }


    public static OverSeaPresenter newInstance() {
        return new OverSeaPresenter();
    }
}
